<?php 

require_once 'i_global.php';
require_once 'func_act_edit.php';

redirectIfNotLoggedIn();

if($_REQUEST['submit'] != NULL) {
	$actID = saveActivity();
	if($actID > 0) {
		// echo "SAVED successfully.";
		header("Location: ${URL_ROOT}show_act.php?activity_id=$actID");
		exit;
	} else {
		echo "ERROR: " . $actID;
	}
} 

$activity_id = $_REQUEST['activity_id'];
if($activity_id > 0) {
	$act = getActivity($activity_id);
}

require_once 'p_header.php';
?>
<div class="span16"><div class="span13">
        <h1><?php echo ($activity_id > 0 ? "Edit" : "Create"); ?> Activity</h1>
        <p>
        </p>
     
        
 <form method="post"">
 		<input type="hidden" name="activity_id" value="<?php echo $act['activity_id']; ?>"/>
        <fieldset>
          <!-- legend>Example form legend</legend-->
          <div class="clearfix">
            <label for="title">Title</label>
            <div class="input">
              <input class="xlarge" id="title" name="title" size="30" type="text" value="<?php echo $act['title']; ?>"/>
            </div>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="description">Description</label>
            <div class="input">
              <textarea class="xxlarge" id="description" name="description" rows="3"><?php echo htmlentities($act['description']); ?></textarea>
            </div>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="extract">Extract</label>
            <div class="input">
              <textarea class="xxlarge" id="extract" name="extract" rows="3"><?php echo htmlentities($act['extract']); ?></textarea>
            </div>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="picture">Picture</label>
            <div class="input">
              <input class="xlarge" id="picture" name="picture" size="30" type="text"  value="<?php echo $act['picture']; ?>"/>
            </div>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="publishedOn">Published on</label>
            <div class="input">
              <input class="xlarge" id="publishedOn" name="publishedOn" size="10" type="text" value="<?php echo $act['published_on']; ?>"/>
            </div>
            <span class="help-block">
                e.g., <b><?php echo date("Y-m-d"); ?></b> or <b><?php echo date("Y-m-d H:i:s"); ?></b>
              </span>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="expiriedOn">Expiried on</label>
            <div class="input">
              <input class="xlarge" id="expiriedOn" name="expiriedOn" size="10" type="text" value="<?php echo $act['expiried_on']; ?>"/>
            </div>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="points">Points</label>
            <div class="input">
              <input class="xlarge" id="points" name="points" size="3" type="text" value="<?php echo $act['points']; ?>"/>
            </div>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="engagement">Engagement</label>
            <div class="input">
              <textarea class="xxlarge" id="engagement" name="engagement" rows="3" value="<?php echo $act['engagement']; ?>"></textarea>
            </div>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="sponser">Sponser</label>
            <div class="input">
              <input class="xlarge" id="sponser" name="sponser" size="30" type="text" value="<?php echo $act['sponser']; ?>"/>
            </div>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="sponser_img">Sponser Logo</label>
            <div class="input">
              <input class="xlarge" id="sponser_img" name="sponser_img" size="30" type="text"  value="<?php echo $act['sponser_img']; ?>"/>
            </div>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="sponser_amount">Sponser Amout</label>
            <div class="input">
              <input class="xlarge" id="sponser_amount" name="sponser_amount" size="3" type="text"  value="<?php echo $act['sponser_amount']; ?>"/>
            </div>
          </div><!-- /clearfix -->
          <div class="clearfix">
            <label for="budget">Budget</label>
            <div class="input">
              <input class="xlarge" id="budget" name="budget" size="3" type="text"  value="10,000.00"/>
            </div>
          </div><!-- /clearfix -->          
          <div class="clearfix">
            <label for="budget">Max per person</label>
            <div class="input">
              <input class="xlarge" id="budget" name="budget" size="3" type="text"  value="3.0"/>
            </div>
          </div><!-- /clearfix -->          

       
          <div class="actions">
            <input type="submit" class="btn primary" name="submit" value="Submit">&nbsp;<button type="reset" class="btn">Cancel</button>
          </div>
        </fieldset>
      </form>        
       
        
</div></div><!-- end div span9 -->
<?php 

require_once 'p_footer.php';

?>